<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>用户管理列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/web/res/css/xadmin.css">
    <script src="/web/res/lib/layui/layui.js" charset="utf-8"></script>
    <script src="/web/res/lib/layui_exts/excel.js" charset="utf-8"></script>
    <script type="text/javascript" src="/web/res/js/xadmin.js"></script>
    <script type="text/javascript" src="/web/res/js/common.js"></script>
</head>

<body>
<div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">用户管理</a>
            <a><cite>用户管理列表</cite></a>
        </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" type="post"  action="/after/user/userList">
                            <div class="layui-input-inline layui-show-xs-block">
                                <input type="text" name="usercode"  value="${usercode!''}"  placeholder="请输入用户账号" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <input type="text" name="loginname"  value="${loginname!''}"  placeholder="请输入登录名" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <input type="text" name="nick"  value="${nick!''}"  placeholder="请输入用户昵称" autocomplete="off" class="layui-input">
                            </div>

                            <div class="layui-input-inline layui-show-xs-block">
                                <select name="states">
                                    <option value="">账号状态（全部）</option>
                                    <#list statesMap?keys as key>
                                    <option value="${key!''}" <#if states?exists && (states)?exists><#if (states)?number == key?number>selected</#if></#if> > <@mapIntString map=statesMap key=key/></option>
                                    </#list>
                                </select>
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <select name="isReal">
                                    <option value="">会员状态（全部）</option>
                                    <#list isRealMaps?keys as key>
                                    <option value="${key!''}" <#if isReal?exists && (isReal)?exists><#if (isReal)?number == key?number>selected</#if></#if> > <@mapIntString map=isRealMaps key=key/></option>
                                </#list>
                                </select>
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <select name="status">
                                    <option value="">实名状态（全部）</option>
                                    <#list userStatusMap?keys as key>
                                    <option value="${key!''}" <#if status?exists && (status)?exists><#if (status)?number == key?number>selected</#if></#if> > <@mapIntString map=userStatusMap key=key/></option>
                                </#list>
                                </select>
                            </div>
                            注册时间：
                            <div class="layui-input-inline layui-show-xs-block">
                                <input class="layui-input" placeholder="开始时间" autocomplete="off" value="${(startDate)!''}" name="startDate" id="startdate">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <input class="layui-input" placeholder="结束时间" autocomplete="off" value="${(endDate)!''}" name="endDate" id="enddate">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <button class="layui-btn"  lay-submit lay-filter="search" >
                                    <i class="layui-icon">&#xe615;</i>搜索
                                </button>
                            </div>
                         </form>
                </div>
                <div class="layui-card">
                    <div class="layui-card-body ">
                    <div class="layui-input-inline layui-show-xs-block">
                        <button class="layui-btn"  onclick="exclea()" >
                            <i class="layui-icon">&#xe615;</i>导出
                        </button>
                    </div>
                        </div>
                </div>

        <div class="layui-card-body"  style="overflow:auto">
            <table class="layui-table layui-form tableH" lay-size="sm"  id="tab">
                            <thead>
                                <tr>
                                    <th style="min-width:40px;">用户账号</th>
                                    <th style="min-width:40px;">登录名</th>
                                    <th style="min-width:70px;">头像</th>
                                    <th style="min-width:40px;">用户昵称</th>
                                    <th style="min-width:40px;">性别</th>
                                    <th style="min-width:40px;">电话</th>
                                    <th style="min-width:40px;">用户等级</th>

                                    <th style="min-width:40px;">邀请码</th>
                                    <th style="min-width:40px;">生日</th>
                                    <th style="min-width:40px;">钻石</th>
                                    <th style="min-width:40px;">金币</th>
                                    <th style="min-width:40px;">贵族状态</th>
                                    <th style="min-width:40px;">贵族等级</th>
                                    <th style="min-width:40px;">账号状态</th>
                                    <th style="min-width:70px;">实名状态</th>
                                    <th>真人照片</th>
                                    <th>身份证审核状态</th>
                                    <th>视频直播权限</th>
                                    <th>音频直播权限</th>
                                    <th>礼物特效状态</th>
                                    <th style="min-width:40px;">粉丝量</th>
                                    <th style="min-width:40px;">关注量</th>
                                    <th style="min-width:70px;">注册时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                            <#if list?? && (list?size > 0) >
                            <#list list as user>
                                <tr>
                                    <td>${(user.usercode?c)!''}</td>
                                    <td>${(user.loginname)!''}</td>
                                    <td>
                                        <#if user.pic?? && user.pic != ''>
                                            <a href="javascript:void(0);" class="img_biges" title="${(user.pic)!''}">
                                            <img src="${(user.pic)!''}" style=" width:35px;height:35px;"/>
                                        <#else>
                                            <div class="divimg"><i class="layui-icon layui-icon-picture-fine"></i>
                                            </div>
                                        </#if>
                                    </td>
                                    <td>${(user.nick)!''}</td>
                                    <td><@mapIntString map=sexMap key=user.sex/></td>
                                    <td>${(user.loginname)!''}</td>
                                    <td>${(user.userlevel)!''}</td>

                                    <td>${(user.code)!''}</td>
                                    <td><#if user.birthday?exists>${(user.birthday?string("yyyy-MM-dd HH:mm:ss"))!}</#if></td>
                                    <td>${(user.diamonds?c)!''}</td>
                                    <td>${(user.jinbi?c)!''}</td>
                                    <td><#if user.isguizu?contains('1')>是<#else>否</#if></td>
                                    <td>${user.guizuname!''}</td>
                                    <td><input type="checkbox" name="states" value="${user.states!''}" lay-skin="switch" lay-text="正常|禁用" {{ user.states != 1 ? 'checked' : '' }}  <#if user.states?exists && (user.states)?number == 1>checked</#if> disabled/></td>
                                    <td><@mapIntString map=userStatusMap key=user.status/></td>
                                    <td>
                                        <#if user.idnumjust?? && user.idnumjust != ''>
                                            <a href="javascript:void(0);" class="img_biges" title="${(user.idnumjust)!''}">
                                            <img src="${(user.idnumjust)!''}" style=" width:35px;height:35px;"/>
                                        <#else>
                                            <div class="divimg"><i class="layui-icon layui-icon-picture-fine"></i>
                                            </div>
                                        </#if>
                                    </td>
                                    <td>
                                        <#if user.shipinstate1?exists && (user.shipinstate1)?number == 1>审核通过
                                        <#elseif user.shipinstate1?exists && (user.shipinstate1)?number == 2>未通过
                                        <#elseif user.shipinstate1?exists && (user.shipinstate1)?number == 3>正在审核
                                        </#if>
                                    </td>
                                    <td><input type="checkbox" name="shipinzb" value="${user.shipinzb!''}" lay-skin="switch" lay-text="开启|关闭" {{ user.shipinzb != 1 ? 'checked' : '' }}  <#if user.shipinzb?exists && (user.shipinzb)?number == 1>checked</#if> disabled/></td>
                                    <td><input type="checkbox" name="yinpinzb" value="${user.yinpinzb!''}" lay-skin="switch" lay-text="开启|关闭" {{ user.yinpinzb != 1 ? 'checked' : '' }}  <#if user.yinpinzb?exists && (user.yinpinzb)?number == 1>checked</#if> disabled/></td>
                                    <td><input type="checkbox" name="giftfunction" value="${user.giftfunction!''}" lay-skin="switch" lay-text="开启|关闭" {{ user.giftfunction != 1 ? 'checked' : '' }}  <#if user.giftfunction?exists && (user.giftfunction)?number == 1>checked</#if> disabled/></td>
                                    <td>${(user.fansnumall)!''}</td>
                                    <td>${(user.guanzhu)!''}</td>
                                    <td><#if user.createtime?exists>${(user.createtime?string("yyyy-MM-dd HH:mm:ss"))!}</#if></td>
                                    <td class="td-manage btn-centers">
                                        <#if user.states?contains('1')>
                                            <button class="layui-btn layui-btn-xs  layui-btn-danger"  onclick="xadmin.open('选择禁用时长','/after/user/selectHour?userId=${(user.id?c)}',500,300)" >
                                                <i class="layui-icon layui-icon-edit"></i>禁用
                                            </button>
                                        </#if>
                                        <#if user.states?contains('2')>
                                            <button class="layui-btn layui-btn-xs  layui-btn-danger"  onclick="upstate(this,'${(user.id?c)!''}',1)" >
                                                <i class="layui-icon layui-icon-edit"></i>解禁
                                            </button>
                                        </#if>
                                        <!--<#if user.yinpinzb?contains('1')>
                                        <button class="layui-btn layui-btn-xs  layui-btn-danger"  onclick="upyuyinstate(this,'${(user.id?c)!''}',2)" >
                                            <i class="layui-icon layui-icon-edit"></i>音频直播权限关闭
                                        </button>
                                        </#if>
                                        <#if user.yinpinzb?contains('2')>
                                        <button class="layui-btn layui-btn-xs  layui-btn-warm"  onclick="upyuyinstate(this,'${(user.id?c)!''}',1)" >
                                            <i class="layui-icon layui-icon-edit"></i>音频直播权限开启
                                        </button>
                                        </#if>
                                        <#if user.status?exists&&user.status?contains('1') &&user.shipinstate?exists&&user.shipinstate?contains('1')>
                                        <#if user.shipinzb?contains('1')>
                                        <button class="layui-btn layui-btn-xs  layui-btn-danger"  onclick="upvideostate(this,'${(user.id?c)!''}',2)" >
                                            <i class="layui-icon layui-icon-edit"></i>视频直播权限关闭
                                        </button>
                                        <#else>
                                            <button class="layui-btn layui-btn-xs  layui-btn-normal"  onclick="upvideostate(this,'${(user.id?c)!''}',1)" >
                                                <i class="layui-icon layui-icon-edit"></i>视频直播权限开启
                                            </button>
                                        </#if>
                                        </#if>-->
                                        <button class="layui-btn layui-btn-xs  layui-btn-normal"  onclick="xadmin.open('用户详情','/after/user/detail?id=${(user.id?c)}',800,500)" >
                                            <i class="layui-icon layui-icon-edit"></i>详情
                                        </button>
                                        <button class="layui-btn layui-btn-xs  layui-btn-normal"  onclick="xadmin.open('查看粉丝信息列表','/after/user/fensi?userid=${(user.id?c)}',1000,600)" >
                                            <i class="layui-icon layui-icon-edit"></i>查看粉丝
                                        </button>
                                        <button class="layui-btn layui-btn-xs  layui-btn-normal"  onclick="xadmin.open('修改钱包','/after/user/updateMoneyDetail?id=${(user.id?c)}')" >
                                            <i class="layui-icon layui-icon-edit"></i>修改钱包
                                        </button>
                                        <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="xadmin.open('个人动态','/after/user/dongtaiDetails?id=${(user.id?c)}',1200,800)" >
                                            <i class="layui-icon layui-icon-log"></i>个人动态
                                        </button>
                                        <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="xadmin.open('发送朋友圈','/after/user/sendDongTaiGetById?id=${(user.id?c)}',800,600)" >
                                            <i class="layui-icon layui-icon-log"></i>发送朋友圈
                                        </button>
                                        <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="xadmin.open('用户收到的礼物详情','/after/user/liwu?id=${(user.id?c)!''}',1000,600)" >
                                            <i class="layui-icon layui-icon-log"></i>收到礼物
                                        </button>
                                        <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="xadmin.open('用户兑换记录','/after/user/dhlist?userid=${(user.id?c)!''}',1000,600)" >
                                            <i class="layui-icon layui-icon-log"></i>兑换记录
                                        </button>
                                        <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="xadmin.open('用户当前坐骑','/after/user/zuoqi?id=${(user.id?c)!''}',1000,600)" >
                                            <i class="layui-icon layui-icon-log"></i>坐骑
                                        </button>
                                        <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="xadmin.open('用户当前头饰','/after/user/headList?id=${(user.id?c)!''}',1000,600)" >
                                            <i class="layui-icon layui-icon-log"></i>头饰
                                        </button>
                                        <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="xadmin.open('查看下级','/after/user/xiajiList?id=${(user.id?c)!''}',1000,600)" >
                                            <i class="layui-icon layui-icon-log"></i>查看下级
                                        </button>
                                        <#if user.isguizu?number == 1 && user.nobleid?number gte 5>
                                            <button class="layui-btn layui-btn-xs layui-btn-normal" onclick="xadmin.open('指定靓号','/after/user/gotoGoodUserCode?userId=${(user.id?c)}',500,300)" >
                                                <i class="layui-icon layui-icon-log"></i>指定靓号
                                            </button>
                                        </#if>
                                    </td>
                                </tr>
                            </#list>
                            <#else>
                                <tr>
                                    <td colspan="20" style="text-align: center;">暂无记录</td>
                                </tr>
                            </#if>
                            </tbody>
                        </table>
                    </div>
                    <!-- 分页条 -->
                    <div id="pager" style="text-align: center;"></div>
                </div>
            </div>
        </div>
    </div>
</body>
<script>

    window.userList ='${mapsJsonStr}';
    function exclea(){
        layui.use(['layer', 'form', 'table', 'laydate','jquery'], function () {
            alert("aaa")
           var list =  JSON.parse(userList);
           var okList = [];
           for (var i=0;i<list.length;i++){
               okList[i] = {};
               okList[i]['nick'] = list[i]['nick'];
               okList[i]['tengxuncode'] = '##'+(list[i]['tengxuncode']).toString();
               okList[i]['pic'] = list[i]['pic'];
               // alert(list[i]['sex']);
               //性别
               if (list[i]['sex'] != undefined) {
                   if (list[i]['sex'] == 1) {
                       okList[i]['sex'] = '男'
                   }
                   if (list[i]['sex'] == 2) {
                       okList[i]['sex'] = '女'
                   }
                   if (list[i]['sex'] == 3) {
                       okList[i]['sex'] = '其他'
                   }
               }
               /*钻石*/
               okList[i]['diamonds'] = list[i]['diamonds'].toString();
               /*金币*/
               okList[i]['jinbi'] = list[i]['jinbi'].toString();
               /*姓名*/
               okList[i]['xingming'] = list[i]['xingming'];
               //经纬度  lon  lat
               if (list[i]['lon'] != undefined && list[i]['lat'] != undefined){

                   okList[i]['address'] = "lon?=" + list[i]['lon'] + "lat?="+ list[i]['lat']
               }

           }
            var date = new Date();


            var excel = layui.excel;
            excel.exportExcel({
                sheet1:okList
            }, '用户资料-'+layui.util.toDateString(date,'yyyy-MM-dd')+'.xlsx', 'xlsx');
        })
    }
    window.onload=function(){
        layui.use(['laydate'], function () {
            let $ = layui.$;
            var laydate = layui.laydate;
            $(".img_biges").click(function(){
                var url = $(this).attr('title');
                var xbcmz =url.split(',');
                $.each(xbcmz, function (index, item) {
                    showimg(item)
                })
            });
            //执行一个laydate实例
            laydate.render({
                elem: '#startdate' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#enddate' //指定元素
            });

        });
    }
    // 删除
    function del(obj, id) {
        layui.use('layer',function () {
            let $ = layui.$;
            layer.confirm('确认要删除吗？', function (index) {
                ajaxPost($,"/role/del",{"idArray":id},function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        });
                    }
                });
            });
        });
    }
    // 管理工会
    function goToTeam(obj,loginname,password,type){
        var l = window.btoa(loginname) // 编码
        var p = window.btoa(password)
        window.open('http://123.60.86.151:81/#/?t=' + type + '&l=' + l+'&p=' + p, '_blank')
    }
    // 账号状态修改
    function upstate(obj, id,state) {
        layui.use('layer',function () {
            let $ = layui.$;
            var text ;
            if(state == 1){
                text = "解除该账户的禁用吗？";
            }else if(state == 2){
                text = "禁用该账户吗？";
            }
            layer.confirm('确认要'+text, function (index) {
                ajaxPost($,"/after/user/upstate",{"id":id,"state":state,"hour":0},function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        });
                    }
                });
            });
        });
    }
    // 会长设置
    function presidentstate(obj, id){
        layui.use('layer',function () {
            let $ = layui.$;
            layer.confirm('确认要开启会长权限吗？', function (index) {
                ajaxPost($,"/after/user/setpresident",{"userId":id},function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        });
                    }
                });
            });
        });
    }
    // 语音直播权限修改
    function upyuyinstate(obj, id,state) {
        layui.use('layer',function () {
            let $ = layui.$;
            var text ;
            if(state == 1){
                text = "开启该权限吗？";
            }else if(state == 2){
                text = "关闭该权限吗？";
            }
            layer.confirm('确认要'+text, function (index) {
                ajaxPost($,"/after/user/upyuyin",{"id":id,"state":state},function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        });
                    }
                });
            });
        });
    }

    // 视频直播权限修改
    function upvideostate(obj, id,state) {
        layui.use('layer',function () {
            let $ = layui.$;
            var text ;
            if(state == 1){
                text = "开启该权限吗？";
            }else if(state == 2){
                text = "关闭该权限吗？";
            }
            layer.confirm('确认要'+text, function (index) {
                ajaxPost($,"/after/user/upvideo",{"id":id,"state":state},function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        });
                    }
                });
            });
        });
    }


    function delAll(argument) {
        var ids = [];
        // 获取选中的id
        $('tbody input[checkid]').each(function (index, el) {
            if ($(this).prop('checked')) {
                ids.push($(this).val())
            }
        });
        var idArray = ids.toString();
        if(idArray.length == 0){
            layer.msg('请选择！', {icon: 2, time: 1000}, function(){});
            return false;
        }
        layui.use('layer',function () {
            let $ = layui.$;
            layer.confirm('确认要删除吗？', function (index) {
                $.ajax({
                    type: "POST",
                    url: "/role/del",
                    dataType: "json",
                    cache: false,
                    async: false,
                    data: {
                        "idArray":idArray
                    },
                    success: function (data) {
                        if (data.code == 0) {
                            layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                                location.reload();
                            });
                        } else {
                            layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                            });
                        }
                    }
                });
            });
        });
    }
</script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['laypage', 'layer', 'form'], function(){
        let $ = layui.$;
        var laypage = layui.laypage
            ,form = layui.form
            ,layer = layui.layer;




        laypage.render({
            elem: 'pager'
            ,count: ${(splitPage.totalCount?c)!''}
            ,limit: ${(splitPage.pageSize?c)!''}
            ,curr: ${(splitPage.pageIndex?c)!''}
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            ,jump: function(obj, first){
                //首次不执行
                if(!first){
                    var myform = document.forms[0];
                    // alert("formName:"+myform.id);
                    var pageIndex = document.createElement("input");
                    pageIndex.name="pageIndex";
                    pageIndex.type="hidden";
                    pageIndex.value=obj.curr;
                    myform.appendChild(pageIndex);

                    var pageSize = document.createElement("input");
                    pageSize.name="pageSize";
                    pageSize.type="hidden";
                    pageSize.value=obj.limit;
                    myform.appendChild(pageSize);
                    // myform.submit();

                    // $("button[lay-filter]")
                    // form.on('submit(button[lay-filter])', function(data){
                    //     // layer.msg(JSON.stringify(data.field));
                    //     // return false;
                    // });
                    // var submitBtn = $("button[lay-submit]");
                    // alert(submitBtn);
                    // console.log(submitBtn)
                    // layer.msg(JSON.stringify(submitBtn));

                    // $('[lay-filter="search"]').click();
                    // $('#chaxun').click();
                    $("button[lay-submit]:eq(0)").click();
                    // $("button[lay-submit]")[0].click();
                    // alert($("#formsubmit").attr("action")+"_获取数量："+obj.limit+"_页码数："+obj.curr);
                    // console.log(obj)
                }
            }
        });
    });
</script>


</html>
